<template>
    <h2>房价设置</h2>
    <table class="table table-bordered">
        <tr>
            <td>房间类型</td>
            <td>
                <input type="text" v-model="info.roomType"/>
            </td>
        </tr>
        <tr>
            <td>单价</td>
            <td>
                <input type="text" v-model="info.price"/>
            </td>
        </tr>
        <tr>
            <td>押金</td>
            <td>
                <input type="text" v-model="info.money"/>
            </td>
        </tr>
        <tr>
            <td>时间</td>
            <td>
                <input type="date" v-model="info.rtime"/>
            </td>
        </tr>
        <tr>
            <td colspan="2">
                <button clsss="btn btn-info" @click="Add">提交</button>
            </td>
        </tr>
    </table>
</template>





<script setup lang="ts">
import {ref} from 'vue'
import axios from 'axios'
import { useRouter } from 'vue-router';
const router=useRouter()

const info=ref({
    roomType:'',
    price:'',
    money:'',
    rtime:'',
    rstate:true
})

const Add=()=>{
    var obj={
        roomType:info.value.roomType,
        price:info.value.price,
        money:info.value.money,
        rtime:info.value.rtime,
        rstate:info.value.rstate
    }
    axios.post('https://localhost:7137/api/Work/RoomAdd',obj)
    .then(res=>{
        if(res.data>0){
            alert('添加成功')
            router.push('/RoomShow')
        }
    })
}

</script>